import {axios} from '@/utils/request'

// api接口列表
const api = {
    list: '/category',
    add: '/category',
    edit: '/category/{id}',
    delete: '/category/{id}'
}

// 列表记录
export function list(params) {
    return axios({
        url: api.list,
        method: 'get',
        params
    })
}

/**
 * 新增记录
 * @param {*} data
 */
export function add(data) {
    return axios({
        url: api.add,
        method: 'post',
        data
    })
}

/**
 * 重命名记录
 * @param {*} id
 * @param {*} data
 */
export function rename(id, data) {
    return axios({
        url: api.edit.replace('{id}', id),
        method: 'put',
        data
    })
}

/**
 * 删除记录
 */
export function deleted(id) {
    return axios({
        url: api.delete.replace('{id}', id),
        method: 'delete'
    })
}
